//引入vue
import Vue from 'vue'
import Vuex from 'vuex'

//注册Vuex
Vue.use(Vuex)

//状态
const state = {
    userinfo: localStorage.getItem('userinfo')
}
//mutations 主要用来操作state
const mutations = {
    // 保存用户数据
    SAVE_USERINFO(state,userinfo) {
        localStorage.setItem('userinfo',userinfo);
        state.userinfo = userinfo;
    }
}

console.log(state.userinfo);

//暴露出来
export default new Vuex.Store({
    state,mutations
})
